package chapter8.java1;

/**
 * @Author juzipi
 * @Date 2021/5/24 14:58
 * @Info
 */
public class ScalarReplace {

    public static class User{
        public int id;
        public String name;
    }

    public static void alloc(){
        User user = new User();//未发生逃逸
        user.id = 2;
        user.name = "你好";
    }

    public static void main(String[] args){
        long start = System.currentTimeMillis();
        for (int i = 0; i < 1000000; i++) {
            alloc();
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start));
    }

}
